var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  getInputValue: () => getInputValue,
  getSystemInfo: () => getSystemInfo,
  getWxMpPluginEnv: () => getWxMpPluginEnv,
  isDevPackage: () => isDevPackage,
  isMpWeixinWeb: () => isMpWeixinWeb,
  saveImage: () => saveImage
});
module.exports = __toCommonJS(stdin_exports);
let systemInfo;
const getSystemInfo = () => {
  if (systemInfo)
    return systemInfo;
  const info = uni.getSystemInfoSync();
  let isMac = info.platform.toLowerCase().includes("mac");
  const isIos = info.system ? info.system.toLowerCase().includes("ios") : isMac;
  let isWeixin = true;
  let isAlipay = false;
  let isApp = false;
  let isMp = false;
  let isMpWeixin = false;
  let isMpAlipay = false;
  isWeixin = false;
  isAlipay = true;
  isMpAlipay = true;
  isMpWeixin = true;
  isMp = true;
  isApp = true;
  const ua = navigator.userAgent;
  isMac = /macintosh|mac os x/i.test(ua);
  isWeixin = /micromessenger/.test(ua.toLowerCase());
  isAlipay = /alipay/.test(ua.toLowerCase());
  let mpMenuButtonRect = uni.getMenuButtonBoundingClientRect && uni.getMenuButtonBoundingClientRect();
  if (!mpMenuButtonRect || !mpMenuButtonRect.left || !mpMenuButtonRect.top || !mpMenuButtonRect.width || !mpMenuButtonRect.height) {
    let gap = 0;
    let width = 96;
    if (info.platform === "devtools") {
      gap = isIos ? 5.5 : 7.5;
    } else {
      gap = isIos ? 4 : 8;
      width = isIos ? 88 : 96;
    }
    if (!info.statusBarHeight) {
      info.statusBarHeight = info.screenHeight - info.windowHeight - 20;
    }
    mpMenuButtonRect = {
      width,
      height: 32,
      bottom: info.statusBarHeight + gap + 32,
      left: info.windowWidth - width - 10,
      right: info.windowWidth - 10,
      top: info.statusBarHeight + gap
    };
  }
  let navBarHeight = 44;
  if (!info.statusBarHeight) {
    navBarHeight = (mpMenuButtonRect.top - (info.screenHeight - info.windowHeight - 20)) * 2 + mpMenuButtonRect.height;
    info.statusBarHeight = 0;
  } else {
    navBarHeight = info.statusBarHeight + (mpMenuButtonRect.top - info.statusBarHeight) * 2 + mpMenuButtonRect.height;
  }
  return {
    devicePixelRatio: info.pixelRatio,
    language: info.language || "",
    windowWidth: info.windowWidth,
    windowHeight: info.windowHeight,
    statusBarHeight: info.statusBarHeight,
    navBarHeight,
    mpMenuButtonRect,
    isIos,
    isMac,
    isWeixin,
    isAlipay,
    isApp,
    isMp,
    isMpWeixin,
    isMpAlipay
  };
};
const isMpWeixinWeb = () => false;
const isDevPackage = () => false;
const getWxMpPluginEnv = () => "";
function getInputValue(event) {
  return event.detail.value;
}
const resolveSaveImgAuth = () => {
  return new Promise((resolve, reject) => {
    let scope = "scope.writePhotosAlbum";
    scope = "scope.album";
    uni.authorize({
      scope,
      success: resolve,
      fail(e) {
        uni.hideLoading();
        uni.showModal({
          title: "\u6E29\u99A8\u63D0\u793A",
          content: "\u8BF7\u5F00\u542F\u76F8\u518C\u6743\u9650\u540E\u518D\u64CD\u4F5C" + JSON.stringify(e),
          confirmText: "\u53BB\u5F00\u542F",
          success: function(res) {
            if (res.confirm) {
              uni.openSetting({});
            }
          }
        });
        reject();
      }
    });
    resolve(1);
  });
};
function saveImage(url) {
  if (!url)
    return;
  uni.showLoading({ title: "\u6B63\u5728\u4FDD\u5B58..." });
  resolveSaveImgAuth().then(() => {
    uni.getImageInfo({
      src: url,
      success(ret) {
        uni.saveImageToPhotosAlbum({
          filePath: ret.path,
          success() {
            uni.hideLoading();
            uni.showToast({ title: "\u5DF2\u4FDD\u5B58\u5230\u76F8\u518C" });
          },
          fail(err) {
            uni.hideLoading();
            uni.showToast({
              title: "\u4FDD\u5B58\u5931\u8D25,\u8BF7\u7A0D\u540E\u91CD\u8BD5..." + err.errMsg,
              icon: "none",
              duration: 2200
            });
          }
        });
      },
      fail(err) {
        uni.hideLoading();
        uni.showToast({
          title: "\u4FDD\u5B58\u5931\u8D25,\u8BF7\u7A0D\u540E\u91CD\u8BD5..." + err.errMsg,
          icon: "none",
          duration: 2200
        });
      }
    });
  });
}
